<template>
  <div class="main">
    <div class="container">
      <div class="box" v-for="(card, index) in cards" :key="index">
        <div class="elements bg"></div>
        <div class="elements img_box">
          <img :src="card.image" style="background-color: #eff7fe;" />
        </div>
        <div class="elements name">
          <h2>{{ card.name }}</h2>
        </div>
        <div class="elements content">
          <p>{{ card.content }}</p>
        </div>
        <div class="card"></div>
      </div>
    </div>
  </div>
</template>

<script>
import VanillaTilt from 'vanilla-tilt'

export default {
  name: 'GlassCard',
  data()
  {
    return {
      cards: [
        {
          image: require('@/assets/admin.jpg'),
          name: '江南韵',
          content: '智柜系统管理员'
        },
        {
          image: 'logo.webp',
          name: '智柜',
          content: '一款基于STM32的高校智能快递柜'
        }
      ]
    }
  },
  mounted()
  {
    VanillaTilt.init(document.querySelectorAll('.box'), {
      max: 15,
      speed: 400,
      glare: true
    })
  }
}
</script>

<style scoped>
*::after,
*::before {
  box-sizing: border-box;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

.main {
  user-select: none;
  overflow-x: hidden;
  font-family: 'Noto Sans SC', sans-serif;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background: url('@/assets/bg1.png') no-repeat center;
  background-size: cover;
}

.container {
  width: 1200px;
  display: flex;
  flex-flow: row wrap;
  justify-content: space-between;
  align-items: center;
}

.box {
  position: relative;
  border-radius: 20px;
  transform-style: preserve-3d;
}

.box .card {
  position: relative;
  background: rgba(255, 255, 255, .1);
  width: 300px;
  min-height: 400px;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, .5);
  border-top: 1px solid rgba(255, 255, 255, .75);
  border-left: 1px solid rgba(255, 255, 255, .75);
  border-radius: 20px;
  box-shadow: 0 25px 45px rgba(0, 0, 0, .05);
  transform-style: preserve-3d;
}

.elements {
  position: absolute;
  top: 50px;
  left: -30px;
  width: 100px;
  height: 100px;
  background: rgba(255, 255, 255, .1);
  transform: translateZ(80px);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, .5);
  border-top: 1px solid rgba(255, 255, 255, .75);
  border-left: 1px solid rgba(255, 255, 255, .75);
  border-radius: 10px;
  box-shadow: 0 25px 45px rgba(0, 0, 0, .05);
}

.elements.bg::before {
  content: '';
  display: block;
  position: absolute;
  inset: 0;
  background: url('@/assets/left_quote.png') no-repeat center;
  background-size: 90%;
  opacity: 0;
  transition: .5s;
}

.box:hover .elements.bg::before {
  opacity: 1;
}

.elements.img_box {
  top: 0;
  left: initial;
  right: 60px;
  width: 120px;
  height: 120px;
  padding: 10px;
  transform: translateZ(120px);
}

.elements.img_box img {
  position: absolute;
  width: calc(100% - 20px);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, .5);
  border-top: 1px solid rgba(255, 255, 255, .75);
  border-left: 1px solid rgba(255, 255, 255, .75);
  box-shadow: 0 25px 45px rgba(0, 0, 0, .05);
  opacity: 0;
  transition: .5s;
}

.box:hover .elements.img_box img {
  opacity: 1;
}

.elements.name {
  top: 250px;
  left: initial;
  right: 0;
  width: 80%;
  height: 10px;
  padding: 0px;
  text-align: center;
  transform: translateZ(180px);
  background: transparent;
  backdrop-filter: blur(0px);
  border: none;
  box-shadow: none;
  color: #644651;
  transition: .5s;
  opacity: 0;
  transition-delay: .25s;
}

.box:hover .elements.name {
  opacity: 1;
  top: 145px;
}

.elements.content {
  top: initial;
  left: initial;
  bottom: 0;
  right: -20px;
  width: 85%;
  min-height: 200px;
  padding: 10px;
  transform: translateZ(180px);
  text-align: center;
  display: flex;
  justify-content: center;
  align-items: center;
}

.elements.content p {
  position: relative;
  color: #FFf;
  font-size: .85em;
  opacity: 0;
  transition: .5s;
  transition-delay: .5s;
  color: #644651;
}

.box:hover .elements.content p {
  opacity: 1;
}
</style>
